package util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;


public class DBUtil {
	private static final String CLASSNAME = "oracle.jdbc.OracleDriver";
	private static final String URL = "jdbc:oracle:thin:@ZHA-ITA092-w7:1522:orcl";
	private static final String PASSWORD = "123";
	private static final String USERNAME = "evan";

	public static Connection createConnection() {
		Connection con = null;
		try {
			Class.forName(CLASSNAME);
			con = DriverManager.getConnection(URL, USERNAME, PASSWORD);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return con;
	}

	public static void close(Connection con, PreparedStatement pst, ResultSet rs) {
		try {
			if (rs != null) {
				rs.close();
			}
			if (pst != null) {
				pst.close();
			}
			if (con != null) {
				con.close();
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
}
